package com.woody.aggregate.common.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Optional;

/**
 * &copy; All rights Reserved
 *
 * @author wénkǎi.zhāng 2025-04-10
 */
@Getter
@RequiredArgsConstructor
public enum ShopPropertyTypeEnum {
    /**
     * 普通
     */
    NORMAL(0),
    /**
     * 主门店
     */
    MAIN(1),
    /**
     * 子门店
     */
    CHILD(2);
    /**
     * 门店类型
     */
    private final Integer type;

    /**
     * 根据门店属性获取门店类型
     *
     * @param shopProperty
     * @return
     */
    public static Optional<ShopPropertyTypeEnum> fromType(Integer shopProperty) {
        if (shopProperty != null) {
            for (ShopPropertyTypeEnum value : values()) {
                if (value.getType().equals(shopProperty)) {
                    return Optional.of(value);
                }
            }
        }

        return Optional.empty();
    }

    /**
     * 是否主门店
     *
     * @param shopProperty
     * @return
     */
    public static boolean isMainShop(Integer shopProperty) {
        return ShopPropertyTypeEnum.MAIN.getType().equals(shopProperty);
    }

    /**
     * 是否子门店
     *
     * @param shopProperty
     * @return
     */
    public static boolean isChildShop(Integer shopProperty) {
        return ShopPropertyTypeEnum.CHILD.getType().equals(shopProperty);
    }

    /**
     * 是否精选门店
     *
     * @param shopProperty
     * @return
     */
    public static boolean isVipShop(Integer shopProperty) {
        return isMainShop(shopProperty) || isChildShop(shopProperty);
    }
}
